package com.sduept.nwld.dataserver.controller.equipment.assessment;

import com.sduept.bigdata.document.entity.core.CommonDocument;
import com.sduept.bigdata.equipment.assessment.model.standardlib.StandardInspection;

import java.util.Comparator;
import java.util.List;
import java.util.Set;


/**
 * @author laiy
 * @Date 2019年7月21日
 * 页面模型对象示例
 */

/**
 * 页面模型对象修改
 * @author huangyu
 * @Date 2019年8月7日
 */
public class TableViewModelItem {
	
	String id;
	String projectNo; // 模块，一、二
	String projectName; // 模块名称，基础管理、保护及二次回路
	Set<CommonDocument> projectDocuments;
	int projectOrder;
	
	String itemNo; // 序号,1.1,1.2,1.3...
	String itemName; // 评价项目
	Set<CommonDocument> itemDocuments;
	int itemOrder;
	
	String inspectionNo;
	String inspectionName; // 检查要素及要求
	Set<CommonDocument> inspectionDocuments;
	int inspectionOrder;
	
	String scoreNo;// 评分标准序号
	String scoreName; // 评分标准名称
	Set<CommonDocument> scoreDocuments;
	int scoreOrder;
	
	String docName; // 检查参照依据
	Set<CommonDocument> documents;
	
	public TableViewModelItem (StandardInspection vo) {
		this.id = vo.getId();
		genItem(vo);
	}
	
	private void genItem(StandardInspection vo) {
		if(vo != null) {
			switch (vo.getItemType()) {
			case INSPECTIONPROJECT:
				projectNo = vo.getNodeNo();
				projectName = vo.getContent();
				projectOrder = vo.getNodeOrder();
				break;
				
			case INSPECTIONITME:
				itemNo = vo.getNodeNo();
				itemName = vo.getContent();
				itemOrder = vo.getNodeOrder();
				break;
				
			case INSPECTIONREQUIREMENT:
				inspectionNo = vo.getNodeNo();
				inspectionName = vo.getContent();
				inspectionOrder = vo.getNodeOrder();
				break;
				
			case INSPECTIONCRITERION:
				scoreNo = vo.getNodeNo();
				scoreName = vo.getContent();
				scoreOrder = vo.getNodeOrder();
				break;
			default:
				break;
			}
			if(vo.getParent() != null) 
				genItem(vo.getParent());
		}
	}
	
	
	/**
	 * 排序，顺序为：projectOrder，itemOrder，inspectionOrder，scoreOrder
	 */
	public static void sortTableViewModelItem(List<TableViewModelItem> selectLists) {
		selectLists.sort(Comparator.comparingInt(TableViewModelItem::getProjectOrder)
			.thenComparingInt(TableViewModelItem::getItemOrder)
			.thenComparingInt(TableViewModelItem::getInspectionOrder)
			.thenComparingInt(TableViewModelItem::getScoreOrder)
			);
	}

	public String getId() {
		return id;
	}

	public String getProjectNo() {
		return projectNo;
	}

	public String getProjectName() {
		return projectName;
	}

	public Set<CommonDocument> getProjectDocuments() {
		return projectDocuments;
	}

	public int getProjectOrder() {
		return projectOrder;
	}

	public String getItemNo() {
		return itemNo;
	}

	public String getItemName() {
		return itemName;
	}

	public Set<CommonDocument> getItemDocuments() {
		return itemDocuments;
	}

	public int getItemOrder() {
		return itemOrder;
	}

	public String getInspectionNo() {
		return inspectionNo;
	}

	public String getInspectionName() {
		return inspectionName;
	}

	public Set<CommonDocument> getInspectionDocuments() {
		return inspectionDocuments;
	}

	public int getInspectionOrder() {
		return inspectionOrder;
	}

	public String getScoreNo() {
		return scoreNo;
	}

	public String getScoreName() {
		return scoreName;
	}

	public Set<CommonDocument> getScoreDocuments() {
		return scoreDocuments;
	}

	public int getScoreOrder() {
		return scoreOrder;
	}

	public String getDocName() {
		return docName;
	}

	public Set<CommonDocument> getDocuments() {
		return documents;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setProjectNo(String projectNo) {
		this.projectNo = projectNo;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public void setProjectDocuments(Set<CommonDocument> projectDocuments) {
		this.projectDocuments = projectDocuments;
	}

	public void setProjectOrder(int projectOrder) {
		this.projectOrder = projectOrder;
	}

	public void setItemNo(String itemNo) {
		this.itemNo = itemNo;
	}

	public void setItemName(String itemName) {
		this.itemName = itemName;
	}

	public void setItemDocuments(Set<CommonDocument> itemDocuments) {
		this.itemDocuments = itemDocuments;
	}

	public void setItemOrder(int itemOrder) {
		this.itemOrder = itemOrder;
	}

	public void setInspectionNo(String inspectionNo) {
		this.inspectionNo = inspectionNo;
	}

	public void setInspectionName(String inspectionName) {
		this.inspectionName = inspectionName;
	}

	public void setInspectionDocuments(Set<CommonDocument> inspectionDocuments) {
		this.inspectionDocuments = inspectionDocuments;
	}

	public void setInspectionOrder(int inspectionOrder) {
		this.inspectionOrder = inspectionOrder;
	}

	public void setScoreNo(String scoreNo) {
		this.scoreNo = scoreNo;
	}

	public void setScoreName(String scoreName) {
		this.scoreName = scoreName;
	}

	public void setScoreDocuments(Set<CommonDocument> scoreDocuments) {
		this.scoreDocuments = scoreDocuments;
	}

	public void setScoreOrder(int scoreOrder) {
		this.scoreOrder = scoreOrder;
	}

	public void setDocName(String docName) {
		this.docName = docName;
	}

	public void setDocuments(Set<CommonDocument> documents) {
		this.documents = documents;
	}

}
